import request from '/@/utils/request'

export interface CalendarEvent {
  id?: string
  title: string
  date: string
  time?: string
  type: 'allday' | 'long' | 'repeating' | 'meeting' | 'conference' | 'birthday' | 'lunch' | 'other'
  staffNo?: string
  description?: string
  billCode?: string
  billStatus?: number
  groupId?: string
  approver?: string
  approvalTime?: string
}

export interface CalendarQuery {
  startDate: string
  endDate: string
  staffNo?: string
  groupId?: string
  type?: string
  billStatus?: number
}

// 获取日历事件
export const getCalendarEvents = (params: CalendarQuery) => {
  return request({
    url: '/api/calendar/events',
    method: 'get',
    params
  })
}

// 创建日历事件
export const createCalendarEvent = (data: CalendarEvent) => {
  return request({
    url: '/api/calendar/events',
    method: 'post',
    data
  })
}

// 更新日历事件
export const updateCalendarEvent = (id: string, data: CalendarEvent) => {
  return request({
    url: `/api/calendar/events/${id}`,
    method: 'put',
    data
  })
}

// 删除日历事件
export const deleteCalendarEvent = (id: string) => {
  return request({
    url: `/api/calendar/events/${id}`,
    method: 'delete'
  })
}

// 移动事件到新日期
export const moveCalendarEvent = (id: string, newDate: string) => {
  return request({
    url: `/api/calendar/events/${id}/move`,
    method: 'patch',
    data: { date: newDate }
  })
}

// 获取员工列表
export const getStaffList = () => {
  return request({
    url: '/api/calendar/staff',
    method: 'get'
  })
}

// 获取部门列表
export const getDepartmentList = () => {
  return request({
    url: '/api/calendar/departments',
    method: 'get'
  })
} 